package com.yzd.learnjava.enumerated;

import com.yzd.learnjava.util.Print;

public class TrafficLight {
	Signal color = Signal.RED;
	public void change() {
		switch (color) {
		case RED:
			color = Signal.GREEN;
			break;
		case GREEN:
			color = Signal.YELLOW;
			break;
		case YELLOW:
			color = Signal.RED;
			break;

		default:
			break;
		}
	}
	
	public String toString() {
		return "The traffic light is " + color;
	}
	
	public static void main(String[] args) {
		TrafficLight light = new TrafficLight();
		for(int i = 0 ; i < 7; i++) {
			Print.print(light);
			light.change();
		}
	}
}

enum Signal{
	GREEN, RED, YELLOW
}
